{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>社区名称：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="社区名称" maxlength="60" name="title" value="{$vo.title ?? ''}"  datatype="*" nullmsg="请填写社区名称">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>详细地址：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="详细地址" maxlength="200" onclick="selectLbs(this)" readonly name="address" value="{$vo.address ?? ''}"  datatype="*" nullmsg="请填写详细地址">
                <input type="hidden" class="input-text" name="lbs" value="">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>联系人：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="联系人" name="lxr" value="{$vo.lxr ?? ''}"  datatype="*" nullmsg="请填写联系人">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>联系电话：</label>
            <div class="formControls col-xs-6 col-sm-6">
                {if condition="isset($vo)"}
                <input type="text" disabled class="input-text" placeholder="联系电话，不可修改，登录帐号" maxlength="20" name="lxr_dh" value="{$vo.lxr_dh}"  datatype="*" nullmsg="请填写联系电话">
                {else /}
                <input type="text" class="input-text" placeholder="联系电话，不可修改，登录帐号" maxlength="20" name="lxr_dh" value=""  datatype="*" nullmsg="请填写联系电话">
                {/if}
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">备注：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="备注" name="note" maxlength="200" value="{$vo.note ?? ''}" >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {


        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){
                ajax_progress(ret);
            }
        });

    });
    var mapLayer = null;
    function selectLbs(e) {
        var lbs = e.value.split(',');
        var p = '?page=1';
        if(2 == lbs.length) {
            p += '&lng='+lbs[0]+'&lat='+lbs[1];
        }
        if( '' !== $('select[name=city]').val() ) {
            var city = $('select[name=city] option:selected').text();
            p += '&city='+ city;
        }
        mapLayer = layer_open('选择','{:\\think\\Url::build(\'map\')}'+p)
    }

    function setMapInfo(j) {
        console.log(j);
        $('input[name=lbs]').val(j.location.lat.toFixed(6) + "," + j.location.lng.toFixed(6));
        $('input[name=address]').val(j.address);
        layer.close(mapLayer);
    }
</script>
{/block}
